package com.situ.mall.user.controller;


import com.situ.mall.common.util.Result;
import com.situ.mall.pojo.entity.user.Address;
import com.situ.mall.user.service.IAddressService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.AutoConfigureOrder;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * <p>
 * 用户地址表 前端控制器
 * </p>
 *
 * @author Gao
 * @since 2024-10-14
 */
@RestController
@RequestMapping("/user/address")
public class AddressController {
    @Autowired
    private IAddressService addressService;

    @GetMapping("/selectByUserId/{id}")
    public Result<List<Address>> selectByUserId(@PathVariable int id) {
        List<Address> list = addressService.selectByUserId(id);
        return Result.ok(list);
    }

    @PostMapping("/add")
    public Result add(@RequestBody Address address) {
        addressService.save(address);
        return Result.ok("添加成功");
    }

}

